/**
 * 
 */
package org.obiwan.subbuteo.model;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.appfuse.model.BaseObject;

/**
 * @author ddefrancesco
 *
 */
@Entity(name="torneo")
@Table(name="torneo")
public class Torneo
    extends BaseObject
{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private Long idTorneo;
    private String nomeTorneo;
    private Partecipante team;
  
    
    

    /**
     * @return the idTorneo
     */
    @Id @GeneratedValue(strategy = GenerationType.AUTO) 
    public Long getIdTorneo()
    {
        return idTorneo;
    }

    /**
     * @return the nomeTorneo
     */
    @Column(name="nome_torneo", length=50)
    public String getNomeTorneo()
    {
        return nomeTorneo;
    }

    /**
     * @return the teams
     */
    @ManyToOne(targetEntity=org.obiwan.subbuteo.model.Partecipante.class, fetch=FetchType.EAGER)
    @JoinColumn(name="team", referencedColumnName="idPartecipante")
    public Partecipante getTeam()
    {
        return team;
    }

    /**
     * @param idTorneo the idTorneo to set
     */
    public void setIdTorneo( Long idTorneo )
    {
        this.idTorneo = idTorneo;
    }

    /**
     * @param nomeTorneo the nomeTorneo to set
     */
    public void setNomeTorneo( String nomeTorneo )
    {
        this.nomeTorneo = nomeTorneo;
    }

    /**
     * @param teams the teams to set
     */
    public void setTeams(Partecipante team )
    {
        this.team = team;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals( final Object other )
    {
        if ( !( other instanceof Torneo ) )
            return false;
        Torneo castOther = (Torneo) other;
        return new EqualsBuilder().append( idTorneo, castOther.idTorneo ).append( nomeTorneo, castOther.nomeTorneo ).append(team,castOther.team ).isEquals();
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode()
    {
        return new HashCodeBuilder().append( idTorneo ).append( nomeTorneo ).append( team).toHashCode();
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString()
    {
        return new ToStringBuilder( this ).append( "idTorneo", idTorneo ).append( "nomeTorneo", nomeTorneo ).append("teams",team ).toString();
    }

}
